package cn.trda.base.refject;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;

import org.junit.Test;

import cn.trda.pojo.Person;

public class IntroseptorDemo {
		@Test
		public void test1() throws IntrospectionException{
			BeanInfo bi=Introspector.getBeanInfo(Person.class);
			//获取一个类中的所有属性
			PropertyDescriptor[] pds=bi.getPropertyDescriptors();
			
			for(PropertyDescriptor pd:pds){
				System.out.println(pd.getName());
				pd.getReadMethod();//public String getUsename(){}
				Method m=pd.getWriteMethod();//public void setUsername(){}
			//	m.invoke(obj, args)
			}
		}
}
